﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <script src="/js/header.js"></script>
</head>
<body style="background-color: white;">
    <section class="container-fluid" style="background-color: white;">
        <form class="form-horizontal m15_t" id="form">
            <div class="tab-content">
                <input type="hidden" id="rId" name="rId" value="0">
                <div class="tab-pane fade in active" id="home">
                    <div class="form-group">
                        <label class="wd100 control-label"><span class="WdateFmtErr">*</span>新密码：</label>
                        <div class="wd250 m15_l">
                            <input class="form-control" type="password" name="newPassWord" id="newPassWord" maxlength="40" autocomplete="off" placeholder="长度必须介于 6 和 40 之间">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="wd100 control-label"><span class="WdateFmtErr">*</span>确认新密码：</label>
                        <div class="wd250 m15_l">
                            <input class="form-control" type="password" name="confirmNewPassWord" maxlength="40" autocomplete="off" placeholder="长度必须介于 6 和 40 之间">
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </section>

    <script type="text/javascript">
        var validator = null;
        $(function () {
            validator = FlashPay.Util.Validator({
                formObj: $("#form"),
                rules: {
                    newPassWord: {
                        required: true,
                        rangelength: [6, 40],
                        abcNum_:true
                    },
                    confirmNewPassWord: {
                        required: true,
                        rangelength: [6, 40],
                        equalTo:"#newPassWord"
                    },
                },
                messages: {
                    newPassWord: {
                        required: "新密码不能为空",
                        rangelength: "长度必须介于 6 和 40 之间",
                        abcNum_: "只能为字母或者数字或下划线"
                    },
                    confirmNewPassWord: {
                        required: "确认新密码不能为空",
                        rangelength: "长度必须介于 6 和 40 之间",
                        equalTo: "两次输入密码不一致"
                    }
                }
            });
        })

        function save() {
            if (!validator.form()) {
                return false;
            }

            let datas = {};
            datas.UID = FlashPay.Util.GetQueryString("uid");
            datas.newPassWord = $("input[name='newPassWord']").val();
            datas.confirmNewPassWord = $("input[name='confirmNewPassWord']").val();
 
            FlashPay.Util.Ajax({
                url: '/Home/ResetPassWord',
                type: 'POST',
                data: datas,
                success: function (response) {
                    if (response.success) {
                        FlashPay.UI.DialogOpener().Tip_success("重设密码成功！");
                        FlashPay.UI.CloseDialog();
                    } else {
                        FlashPay.UI.Tip_short_warning("重设密码失败！" + response.errorMessage);
                    }
                },
                error: function (json) {
                    FlashPay.UI.Tip_short_warning("操作失败！请查看网络，请重试。");
                }
            });
        }
    </script>
</body>
</html>